﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:core="clr-namespace:Eniux.Windows.Controls.Core.Core;assembly=Eniux.Windows.Controls.Core"
                    xmlns:btns="clr-namespace:Eniux.Windows.Controls.Buttons;assembly=Eniux.Windows.Controls">
    <Style  TargetType="btns:SplitButton">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Background" Value="{DynamicResource NormalBrush_Button}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource NormalBorderBrush_Button}"/>
        <Setter Property="Foreground" Value="{DynamicResource ForegroundBrush_Button}" />
        <Setter Property="FontFamily" Value="SimSun" />
        <Setter Property="FontSize" Value="13" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="btns:SplitButton">
                    <Border BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="3">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition Width="20"/>
                            </Grid.ColumnDefinitions>
                            <Button Command="{TemplateBinding Command}"
                                    CommandParameter="{TemplateBinding CommandParameter}"
                                    Content="{TemplateBinding Header}"
                                    Tag="{TemplateBinding Tag}" 
                                    BorderThickness="0,0,1,0" 
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    core:AttachBase.CornerRadius="1.75,0,0,1.75"
                                    Style="{DynamicResource Button_SplitButton}"
                                    />
                            <Button x:Name="PART_DownButton" Grid.Column="1" BorderThickness="0" Style="{DynamicResource Button_SplitButton}" core:AttachBase.CornerRadius="0,1.75,1.75,0">
                                <Path IsHitTestVisible="False" x:Name="BtnArrow" Margin="0,0,0,0" Width="6" Fill="{DynamicResource GlyphBrush_ComboBox}" Stretch="Uniform" Data="F1 M 301.14,-189.041L 311.57,-189.041L 306.355,-182.942L 301.14,-189.041 Z "/>
                            </Button>
                            <Popup x:Name="PART_Children" IsOpen="{TemplateBinding Sys_IsDropDownOpen}" StaysOpen="False" PlacementTarget="{Binding ElementName=PART_DownButton}" Placement="Bottom"  Focusable="True" AllowsTransparency="True" PopupAnimation="Slide" Margin="0,0,0,0">
                                <Grid MaxHeight="{TemplateBinding Sys_MaxDropDownHeight}" MinWidth="{TemplateBinding ActualWidth}" x:Name="DropDown" SnapsToDevicePixels="True">
                                    <Border Margin="0,0,0,0" BorderBrush="{DynamicResource BorderBrush_ComboBox}" BorderThickness="1" CornerRadius="0,0,0,0" Background="{DynamicResource BackgroundBrush_ComboBoxDropDown}">
                                        <ScrollViewer  Margin="1" SnapsToDevicePixels="True" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
                                            <StackPanel x:Name="childrenContainer" IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Contained"/>
                                        </ScrollViewer>
                                    </Border>
                                </Grid>
                            </Popup>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style  TargetType="{x:Type btns:SplitButtonItem}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Padding" Value="5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type btns:SplitButtonItem}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="HighlightOn">
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="1.0" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientInnerOver" Storyboard.TargetProperty="Opacity" To="1.0" />
                        </Storyboard>
                        <Storyboard x:Key="HighlightOff">
                            <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundGradientOver" Storyboard.TargetProperty="Opacity" To="0" />
                            <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundGradientInnerOver" Storyboard.TargetProperty="Opacity" To="0.0" />
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid SnapsToDevicePixels="true">
                        <Rectangle x:Name="BackgroundGradientOver" RadiusX="3" RadiusY="3" Stroke="{DynamicResource MouseOverBorderBrush_ListItem}" Opacity="0" Fill="{DynamicResource MouseOverBrush_ListItem}"/>
                        <Rectangle x:Name="BackgroundGradientInnerOver" Margin="1" RadiusX="3" RadiusY="3" Stroke="{DynamicResource MouseOverInnerBorderBrush_ListItem}" Opacity="0" Fill="Transparent"/>
                        <ContentPresenter x:Name="contentPresenter" Content="{TemplateBinding Header}"  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" />
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.ExitActions>
                                <BeginStoryboard Storyboard="{StaticResource HighlightOff}" x:Name="HighlightOff_BeginStoryboard" />
                            </Trigger.ExitActions>
                            <Trigger.EnterActions>
                                <BeginStoryboard Storyboard="{StaticResource HighlightOn}" x:Name="HighlightOn_BeginStoryboard"/>
                            </Trigger.EnterActions>
                        </Trigger>

                        <Trigger Property="IsEnabled" Value="false">
                            <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush_Button}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>